-
Notifications
You must be signed in to change notification settings - Fork 6
Доступ к id загруженных файлов + Исправление сохранения внутренних сообщений Spring AI в ChatResponseMetadata #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ледующего доступа к ним Signed-off-by: Linar Abzaltdinov <abzaltdinov@gmail.com>
* Исправление сохранения внутренних сообзений Spring AI в ChatResponseMetadata Signed-off-by: Linar Abzaltdinov <abzaltdinov@gmail.com>
*/ | ||
private List<Message> uploadMedia(List<Message> messages) { | ||
return messages.stream() | ||
.map(message -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Смотрится страшненько, может вынесем в отдельный метод?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
исправил
return messages.stream() | ||
.map(message -> { | ||
if (message instanceof UserMessage userMessage | ||
&& !CollectionUtils.isEmpty(userMessage.getMedia())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Предлагаю разбить на два условия сразу с выходом return message;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
исправил
.map(message -> { | ||
if (message instanceof UserMessage userMessage | ||
&& !CollectionUtils.isEmpty(userMessage.getMedia())) { | ||
var mediaWithIds = userMessage.getMedia().stream() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Также предлагаю вынести в отдельный метод
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
исправил
|
||
List<Message> messages = prompt.getInstructions(); | ||
|
||
// ищем индекс последнего пользовательского сообщения, т.к. здесь могут быть сообщения из ChatMemory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Также лучше вынести в отдельный метод логику поиска и последнего сообщения также с условием типизации под UserMessage
, так как ниже есть оптимистичный каст под него, что не очень хорошо
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
логику могу вынести, ок - но результатам метода будет индекс, int.
мне в одном месте нужен индекс, а в другом уже объект UserMessage, от каста не избавлюсь
Signed-off-by: Linar Abzaltdinov <abzaltdinov@gmail.com>
Uh oh!
There was an error while loading. Please reload this page.